package org.autumn.thread;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

public class ParkMethod {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            System.out.println("park ...");
            LockSupport.park();
            System.out.println("uppark ...");
            // Thread.interrupted() 会把打断标记重置为false,下面的park才会生效
            System.out.println(Thread.interrupted() );

            LockSupport.park();
            System.out.println("uppark ...");
        }, "t1");

        t1.start();

        TimeUnit.SECONDS.sleep(1);
        // 打断park线程
        t1.interrupt();
    }
}
